package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.common.result.ResultCodeEnum;
import com.atguigu.gmall.model.product.Item;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author atguigu-mqx
 * @Description TODO
 * @Date 2023/5/8 9:10
 * @Version 1.0
 */
@RestController
@RequestMapping("/admin")
public class ItemController {

    //  @RequestBody 接受前端传递的json 数据变为实体类
    @PostMapping("saveItem")
    public Result saveItem(@RequestBody Item item){
        //  编写一个运行时异常
        int i = 1/0;
        //  返回添加成功.
        return Result.build(item, ResultCodeEnum.SUCCESS);
    }
}
